<% include ../header.ejs %>

<link rel="stylesheet" href="/lib/datetimepicker/css/amazeui.datetimepicker.css"/>

<script src="/lib/datetimepicker/js/amazeui.datetimepicker.min.js"></script>
<script src="/lib/datetimepicker/js/locales/amazeui.datetimepicker.zh-CN.js"></script>

<header data-am-widget="header" data-am-sticky class="am-header am-header-default" id="appTemplates-Nav">
    <div class="am-header-left am-header-nav">
        <a href='javascript:history.go(-1)' class="">
            <img class="am-header-icon-custom" src="data:image/svg+xml;charset&#x3D;utf-8,&lt;svg xmlns&#x3D;&quot;http://www.w3.org/2000/svg&quot; viewBox&#x3D;&quot;0 0 12 20&quot;&gt;&lt;path d&#x3D;&quot;M10,0l2,2l-8,8l8,8l-2,2L0,10L10,0z&quot; fill&#x3D;&quot;%23fff&quot;/&gt;&lt;/svg&gt;" alt=""/>
        </a>
    </div>
    <%
     var operationType = {add:['新建','保存',true],edit:['编辑','保存',true],detail:['查看','编辑',false]};
     var operation = operationType[pageType];
    %>
    <h1 class="am-header-title">
        <a href="#title-link" class="" id="Typeface-whitecolor"><%=operation[0]%>其他</a>
    </h1>
    <div class="am-header-right am-header-nav">
        <a <%if (!operation[2]){%> href="page?pageType=edit&rowId=<%=workdiary.rowId%>" <%}else{%> onclick="javascript:$('#save').click();"<%}%> class="" data-am-modal="{target: '#modal-type-add', closeViaDimmer: 0, width: 240, height: 260}"><%=operation[1]%></a>
    </div>
</header>
<script>
    var startTime,finishTime;
    <%if (pageType!='add'){%>
        startTime = new Date('<%=workdiary.startTime%>');
        finishTime = new Date('<%=workdiary.finishTime%>');
    <%}else{%>
        startTime = new Date();
        finishTime = new Date();
        finishTime.setHours(startTime.getHours()+1);
    <%}%>
</script>

<form name="addworkdiary" id="addworkdiary" class="am-form" method="post" action="<%=pageType%>" data-am-validator>
    <fieldset>
        <div style="margin-top:5px;margin-bottom: 0rem;">
            <label for="doc-vld-name">标题:</label>
            <input id="title" name="title" type="text" <%if(pageType!='add'){%>value="<%=workdiary.title%>"<%}%>
                   <%if (!operation[2]){%> readonly <%}%>placeholder="请输入标题"/>
        </div>

        <div class="am-form-group" style="margin-top:5px;">
            <label for="doc-vld-name">开始时间:</label>
            <%if (operation[2]){%>
            <div class="am-input-group date" id="start_datetime" data-date-format="yyyy-mm-dd hh:ii">
            <%}%>
                <input name="startTime" id="startTime" type="text"  placeholder="开始时间" class="am-form-field" readonly required>
            <%if (operation[2]){%>
                <span class="am-input-group-label  add-on" ><i class="icon-th am-icon-calendar"></i></span>
            </div>
            <%}%>
        </div>

        <div class="am-form-group" style="margin-top:5px;">
            <label for="doc-vld-name">结束时间:</label>
            <%if (operation[2]){%>
            <div class="am-input-group date" id="end_datetime" data-date-format="yyyy-mm-dd hh:ii">
             <%}%>
                <input name="finishTime" id="finishTime" type="text" placeholder="结束时间" class="am-form-field" readonly required>
            <%if (operation[2]){%>
                <span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
            </div>
            <%}%>
        </div>

        <div  style="margin-top:5px;margin-bottom: 0rem;">
        <label for="doc-vld-name">内容:</label>
            <textarea name="content" id="content" rows="10"<%if (!operation[2]){%> readonly <%}%>placeholder="请输入内容"><%=workdiary.content||''%></textarea>
        </div>

        <%if(pageType!='add'){%>
          <input type="hidden" name="rowId" value="<%=workdiary.rowId%>">
        <%}%>
    </fieldset>
    <button class="am-btn am-btn-secondary" type="submit" id="save" style="visibility:hidden">保存</button>
</form>

<%if(!operation[2]){%>
<form class="am-form" method="post" action="delete">
    <fieldset>
        <input type="hidden" name="rowId" value="<%=workdiary.rowId%>"/>
        <button type="button" class="am-btn am-btn-danger am-btn-block" onclick="submit()"><i class="am-icon-minus"></i> 删除</button>
    </fieldset>
</form>
<%}%>

<script src="/javascripts/app/schedule/workdiary_add.js"></script>
<% include ../footer.ejs %>
